package me.firstapp.module.shop;

import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import me.firstapp.module.base.CommonEntity;

@Entity
@Table(name = "PRODUCT_PRODUCT")
public class Product extends CommonEntity {

	private static final long serialVersionUID = 5959482150108318643L;

	// 与种类关联
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CATEGORY_ID", nullable = false, referencedColumnName = "ID")
	private Category category;

	// 列表图片(在商品列表展示中显示的图片)
	@Column(name = "LIST_IMAGE", length = 200, nullable = false)
	private String listImage;

	// 小图片
	@Column(name = "SMALL_IMAGE", length = 200, nullable = false)
	private String smallImage;

	// 其它图片，用逗号隔开
	@Column(name = "IMAGES", columnDefinition = "TEXT", nullable = true)
	private String images;

	// 商品名称
	@Column(name = "NAME", length = 50, unique = true, nullable = false)
	private String name;

	// 商品简介
	@Column(name = "SUMMARY", length = 240, nullable = false)
	private String summary;

	// 商品详情
	@Column(name = "DETAIL", columnDefinition = "TEXT", nullable = false)
	private String detail;

	// 配送方式(快递,平邮等)
	@Column(name = "DELIVER", length = 20, nullable = false)
	private String deliver;

	// 运费
	@Column(name = "DELIVER_FEE", columnDefinition = "DECIMAL(11, 2)", nullable = false)
	private Double deliverFee = 0.00;

	// 是否上下架，0为下架，1为上架，默认为下架（只有维护了sku才能上架）
	@Column(name = "DISABLE", columnDefinition = "TINYINT DEFAULT 0", nullable = false)
	private Integer disable;

	// 浏览数
	@Column(name = "VIEW_COUNTS", columnDefinition = "BIGINT", nullable = false)
	private Long viewCounts = 0L;

	// 评论数
	@Column(name = "REPLY_COUNTS", columnDefinition = "BIGINT", nullable = false)
	private Long replyCounts = 0L;

	// 收藏数
	@Column(name = "COLLECT_COUNTS", columnDefinition = "BIGINT", nullable = false)
	private Long collectCounts = 0L;

	// 排序
	@Column(name = "SORT", columnDefinition = "TINYINT", nullable = false)
	private Integer sort;

	// 添加时间
	@Column(name = "ADD_TIME", columnDefinition = "DATETIME", nullable = false)
	private Date addTime;
	
	//==========以下是冗余字段===================================================================
	
	@Column(name = "PRODUCT_SKU_REL_ID", nullable = true)
	private Long productSkuRelationId;
	
	// 属性名1
	@Column(name = "SKU_NAME_ONE", length = 10, nullable = true)
	private String skuName1;

	// 属性值1
	@Column(name = "SKU_VALUE_ONE", length = 10, nullable = true)
	private String skuValue1;

	// 属性名2
	@Column(name = "SKU_NAME_TWO", length = 10, nullable = true)
	private String skuName2;

	// 属性值2
	@Column(name = "SKU_VALUE_TWO", length = 10, nullable = true)
	private String skuValue2;

	// 库存
	@Column(name = "STOCK", nullable = true)
	private Integer stock;

	// 价格
	@Column(name = "PRICE", columnDefinition = "DECIMAL(11, 2)", nullable = true)
	private Double price;
	
	public Long getProductSkuRelationId() {
		return productSkuRelationId;
	}

	public void setProductSkuRelationId(Long productSkuRelationId) {
		this.productSkuRelationId = productSkuRelationId;
	}

	@Transient
	private Set<ProductSkuRelation> skuRelations = new LinkedHashSet<>();

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public String getListImage() {
		return listImage;
	}

	public void setListImage(String listImage) {
		this.listImage = listImage;
	}

	public String getSmallImage() {
		return smallImage;
	}

	public void setSmallImage(String smallImage) {
		this.smallImage = smallImage;
	}

	public String getImages() {
		return images;
	}

	public void setImages(String images) {
		this.images = images;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	public Long getViewCounts() {
		return viewCounts;
	}

	public void setViewCounts(Long viewCounts) {
		this.viewCounts = viewCounts;
	}

	public Long getReplyCounts() {
		return replyCounts;
	}

	public void setReplyCounts(Long replyCounts) {
		this.replyCounts = replyCounts;
	}

	public Long getCollectCounts() {
		return collectCounts;
	}

	public void setCollectCounts(Long collectCounts) {
		this.collectCounts = collectCounts;
	}

	public Integer getDisable() {
		return disable;
	}

	public void setDisable(Integer disable) {
		this.disable = disable;
	}

	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public String getDeliver() {
		return deliver;
	}

	public void setDeliver(String deliver) {
		this.deliver = deliver;
	}

	public Double getDeliverFee() {
		return deliverFee;
	}

	public void setDeliverFee(Double deliverFee) {
		this.deliverFee = deliverFee;
	}

	public Set<ProductSkuRelation> getSkuRelations() {
		return skuRelations;
	}

	public void setSkuRelations(Set<ProductSkuRelation> skuRelations) {
		this.skuRelations = skuRelations;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public String getSkuName1() {
		return skuName1;
	}

	public void setSkuName1(String skuName1) {
		this.skuName1 = skuName1;
	}

	public String getSkuValue1() {
		return skuValue1;
	}

	public void setSkuValue1(String skuValue1) {
		this.skuValue1 = skuValue1;
	}

	public String getSkuName2() {
		return skuName2;
	}

	public void setSkuName2(String skuName2) {
		this.skuName2 = skuName2;
	}

	public String getSkuValue2() {
		return skuValue2;
	}

	public void setSkuValue2(String skuValue2) {
		this.skuValue2 = skuValue2;
	}

	public Integer getStock() {
		return stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

}
